package com.xianyun.site.support.dto;

import com.xianyun.common.core.utils.DateToolUtils;
import com.xianyun.common.core.utils.FormatUtils;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.UUID;

/**
 * @author mac_zyj
 */
@Data
public class SmtpSendCmd {
    @NotEmpty(message = "发送方不能为空")
    private String toAddress;
    @NotEmpty(message = "模块名称不能为空")
    private String model;
    @NotNull(message = "类型不能为空")
    private Integer type;
    private String session;

    private SmtpReceiveCmd receiveCmd;

    public void initSmtp(){
        receiveCmd = new SmtpReceiveCmd();
        BeanUtils.copyProperties(this,receiveCmd,SmtpReceiveCmd.class);
        receiveCmd.getSmtpMessage().setCheckCode(FormatUtils.getCheckCode());
        receiveCmd.getSmtpMessage().setSendId(FormatUtils.getSerialNumber());
        receiveCmd.getSmtpMessage().setCurrentTime(DateToolUtils.getNowDate());
        receiveCmd.getSmtpMessage().setTransactionId(UUID.randomUUID().toString());
    }
}
